/*
 * TarifaBuilderPaso1.java
 *
 * Created on 4 de junio de 2007, 11:13 AM
 */

package inc.jmc.cyberboard.ui.ventas;

import inc.jmc.cyberboard.Tarifa;
import inc.jmc.cyberboard.common.DefaultLookAndFeel;
import javax.swing.JOptionPane;

/**
 *
 * @author  JOlguin01
 */
public class TarifaBuilderPaso1 extends javax.swing.JPanel {
    
    /** Creates new form TarifaBuilderPaso1 */
	TarifaBuilderFrm parent;
    public TarifaBuilderPaso1(TarifaBuilderFrm parent) {
        initComponents();
        this.nTxt.requestFocus();
        this.parent=parent;
    }

    public javax.swing.JTextField getNTxt() {
        return nTxt;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        nTxt = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        nextButton = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();

        setLayout(null);

        jPanel1.setLayout(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Paso 1");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(10, 10, 110, 20);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setText("<html>Dividir una hora en N fracciones iguales</html>");
        jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        jPanel1.add(jLabel2);
        jLabel2.setBounds(50, 50, 130, 50);

        jPanel1.add(nTxt);
        nTxt.setBounds(50, 110, 70, 19);

        jLabel3.setText("fracciones");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(130, 110, 70, 20);

        add(jPanel1);
        jPanel1.setBounds(10, 20, 260, 210);

        nextButton.setText(">>");
        nextButton.setToolTipText("");
        nextButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextButtonActionPerformed(evt);
            }
        });

        add(nextButton);
        nextButton.setBounds(220, 240, 49, 23);

        jButton2.setText("<<");
        jButton2.setEnabled(false);
        add(jButton2);
        jButton2.setBounds(120, 240, 49, 23);

        cancelButton.setText("Cancelar");
        cancelButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        add(cancelButton);
        cancelButton.setBounds(20, 240, 73, 23);

    }// </editor-fold>//GEN-END:initComponents

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed

        parent.tarifaAux=new Tarifa();
        parent.getContentPane().remove(parent.paso1);
        parent.getContentPane().add(parent.getJPanel1(), java.awt.BorderLayout.CENTER);
        parent.updateUI();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed

        String a=getNTxt().getText();
        if(a!=null && !a.equals(""))
        {
        	try {
        		int N=Integer.parseInt(a);
                parent.tarifaAux.setFraccionesHora(N);
                parent.getContentPane().remove(parent.paso1);
                parent.getContentPane().add(parent.paso2, java.awt.BorderLayout.CENTER);
                parent.paso2.dibujaReloj();
                parent.paso2.updateUI();
                parent.updateUI();
                
			} catch (NumberFormatException  ex) {
				JOptionPane.showMessageDialog(this,"Introduzca un valor numerico entero-"+ex.getMessage(),"Verifique los datos proporcionados",JOptionPane.ERROR_MESSAGE);
				
			}
            
        }
    }//GEN-LAST:event_nextButtonActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelButton;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField nTxt;
    private javax.swing.JButton nextButton;
    // End of variables declaration//GEN-END:variables
    
}
